#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

char lookahead;

void expr();
void term();
void factor();
void error();

void skip_space()
{
    while (isspace(lookahead))
    {
        lookahead = getchar();
    }
}

void match(char c)
{
    while (isspace(lookahead))
    {
        lookahead = getchar();
    }
    if (lookahead == c)
    {
        lookahead = getchar();
    }
    else
    {
        error();
    }
}

void error()
{
    printf("syntax error\n");
    exit(1);
}

void expr()
{
    term();
    skip_space();
    while (lookahead == '+' || lookahead == '-')
    {
        match(lookahead);
        term();
    }
}

void term()
{
    factor();
    skip_space();
    while (lookahead == '*' || lookahead == '/')
    {
        match(lookahead);
        factor();
    }
}



void factor()
{
   skip_space();
    if (isdigit(lookahead))
    {
        while (isdigit(lookahead))
        {
            match(lookahead);
        }
    }
    else if (lookahead == '(')
    {
        match('(');
        expr();
        match(')');
    }
    else
    {
        error();
    }
}

int main()
{
    lookahead = getchar();
    expr();
    skip_space();
    if (lookahead != EOF)
    {
        error();
    }
    printf("syntax is correct\n");
    return 0;
}